<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Stast extends CI_Controller{    	
    function __construct(){
		parent::__construct();
	}
    function index(){   
        $mem=0;
        $offer=0;
        $mem = $this->Home_model->get_number('users');
        $offer = $this->Home_model->get_number('offer');
        $g =$this->Home_model->get_data('users_group',array('idgroup'=>0),'','','',array('id'));
        if(!empty($g)){
            foreach ($g as $g){
                $mg[] = $g->id;
            }
        }else{
            $mg[]=0;
        }
        
        $this->db->select_sum('point');
        $this->db->where_in('iduser',$mg);
        $t = $this->db->get('history')->row();
        if(!$t){
            $t->point = 0;
        }
        $this->db->update('stast',array('mem'=>$mem,'offer'=>$offer,'paid'=>$t->point));
        redirect(base_url().'admin');
    }
    
}